package edu.ccut.saturn.manager.bundles.core;

import java.util.ArrayList;
import java.util.List;

import edu.ccut.saturn.component.DefaultComponent;
import edu.ccut.saturn.component.IParameterContext;
import edu.ccut.saturn.component.SaturnData;

public class QueryAppBundlesList extends DefaultComponent {
	@SuppressWarnings("unchecked")
	@Override
	public void execute(IParameterContext parameterContext) throws Exception {

		List<SaturnData> allBundleList = (List<SaturnData>) parameterContext
				.getParameterValue(0);

		List<SaturnData> appBundleList = new ArrayList<SaturnData>();

		for (SaturnData bundleInfo : allBundleList) {
			String bundleFilePath = bundleInfo.getString("bundleFilePath");
			if (bundleFilePath != null
					&& bundleFilePath.indexOf("\\plugins") != -1) {
				appBundleList.add(bundleInfo);
			}
			if (bundleFilePath.indexOf("\\1") != -1
					|| bundleFilePath.indexOf("\\2") != -1) {
			}
			if (bundleInfo.getString("key").equals("System Bundle")) {

			}
			appBundleList.add(bundleInfo);

		}

		parameterContext.setParameter(1, appBundleList);
	}
}